package javabase.schoolwork.day7_13.d13.d13;

import org.junit.Test;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

/**
 * @author Tse
 * JDK7 JDK8 新特性
 */
public class JunitTest1 implements Inter{
	@Override
	public void show() {
		
	}
	/*
	 * try-with-resources语句
	 * */
	@Test
	public void fun1() {
		try(FileReader fr=new FileReader("f.txt");
			FileWriter fw=new FileWriter("w.txt");){
			int ch=0;
			while((ch=fr.read())!=-1) {
				fw.write(ch);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	@Test
	public void fun2() {
		defaultPrint();
	}

	@Test
	public void fun3() {
		defaultPrint();
	}
	
}

/*
 * JDK8新特性：接口里可以有默认方法实现
 * 
 *
 */
interface Inter{
	public abstract void show();
	
	public default void defaultPrint() {
		System.out.println("接口的默认方法");
	}
	
	public static void staticPrint() {
		System.out.println("接口的静态方法");
	}
}


